/**
 * Created by JiaJia on 2019/5/22 0022.
 * 丑数
 */
public class Code34 {
    public int GetUglyNumber_Solution(int index) {
        if (index<=0){
            return 0;
        }
        int[] arr = new int[index];
        int times2=0;
        int times3=0;
        int times5=0;
        arr[0]=1;
        for (int i = 1; i <index ; i++) {
            arr[i]=Math.min(arr[times2]*2,Math.min(arr[times3]*3,arr[times5]*5));
            if (arr[times2]*2==arr[i])
                times2++;
            if (arr[times3]*3==arr[i])
                times3++;
            if (arr[times5]*5==arr[i])
                times5++;
        }
        return arr[index-1];
    }
}